package com.dunqi.gpm.shunqing.home.adapter;

import android.support.annotation.Nullable;
import android.view.View;

import com.chad.library.adapter.base.BaseViewHolder;
import com.dunqi.gpm.shunqing.R;
import com.dunqi.gpm.shunqing.common.base.RecyclerAdapter;
import com.dunqi.gpm.shunqing.home.bean.YearPlan;
import com.dunqi.gpm.shunqing.home.constance.Constance;
import com.dunqi.gpm.shunqing.home.widget.NormalView;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;

/**
 * Created by Administrator on 2017/11/26.
 */

public class YearPlanAdapter extends RecyclerAdapter<YearPlan> {

    private final String[] status;

    public YearPlanAdapter(@Nullable List<YearPlan> data) {
        super(R.layout.item_year_plan, data);
        status = Constance.STATUS;
    }

    @Override
    protected void convert(BaseViewHolder helper, YearPlan item) {
        helper.setText(R.id.title_tv, item.getPlanYear() + "年度计划");
        NormalView contentView = helper.getView(R.id.year_plan_content_tv);
        contentView.setText(item.getConstructionDescWholeYear());

        NormalView totalMoneyView = helper.getView(R.id.plan_total_money_tv);
        totalMoneyView.setText(String.valueOf(item.getTotalInvestmentAmount()));


        NormalView planStartTimeView = helper.getView(R.id.plan_start_time_tv);
        planStartTimeView.setText(String.valueOf(item.getPlanStartTime()));


        NormalView planEndTimeView = helper.getView(R.id.plan_end_time_tv);
        planEndTimeView.setText(item.getPlanCompleteTime());


        NormalView buildKindView = helper.getView(R.id.build_kind_tv);
        buildKindView.setText(item.getConstructionTypeText());


        NormalView writeNameView = helper.getView(R.id.write_name_tv);
        writeNameView.setVisibility(View.GONE);
        writeNameView.setText(item.getCreaterName());

        NormalView auditStateView = helper.getView(R.id.audit_state_tv);
        int auditStatus = item.getAuditStatus();

        auditStateView.setText(status[auditStatus]);
//
//        NormalView writeTimeView = helper.getView(R.id.write_time_tv);
//        writeTimeView.setText(item.getCreateTime());

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//        sdf.format(new Date(item.getCreateTime()));
        try {
            NormalView writeTimeView = helper.getView(R.id.write_time_tv);
            writeTimeView.setText(sdf.format(sdf.parse(item.getCreateTime())));

        } catch (ParseException e) {
            e.printStackTrace();
        }
        //20180426
        contentView.setVisibility(View.GONE);
        planStartTimeView.setVisibility(View.GONE);
        planEndTimeView.setVisibility(View.GONE);
        auditStateView.setVisibility(View.GONE);
        buildKindView.setVisibility(View.GONE);
    }


}
